package ibm.websphere.monitor.tablib;

import javax.servlet.jsp.JspException;


import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.Tag;
import javax.servlet.jsp.tagext.TagSupport;

/**
 * @copyright www.timotai.net
 * @author 这家伙真懒
 * @date 2016-1-12
 * <pre></pre>
 **/
public class WasPageTag extends TagSupport {

    private static final long serialVersionUID = 4470103400561540261L;


    //分页模板
    private String type = "TEXT";

    @Override
    public int doStartTag() throws JspException {

        ServletRequest request = pageContext.getRequest();

        //获取分页模板
        String pageTemplate = PageELFunction.renderPage(type);

        RequestDispatcher disp = request.getRequestDispatcher(pageTemplate);

        try {
            disp.include(request, pageContext.getResponse());
        } catch (ServletException ex) {
            //LogUtils.info("彩信平台", "[IdeaPageTag]加载分页模板 HTTP 500 错误：" + ex.getMessage());
        } catch (IOException ex) {
            //LogUtils.error("彩信平台", "[IdeaPageTag]分页模板I/O错误:" + ex.getMessage());
        }
        return Tag.EVAL_PAGE;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getType() {
        return this.type;
    }
}
